<style>
     .footer-home{display: none}
     .item_ul .item_list>b{margin-right: 0.2rem;}
</style>
<header>
    <a href="index.php">
        <i class="iconfont icon-xialalan-copy"></i>
    </a>
    <span class="search_icon  iconfont icon-search"></span>
    <form action="index.php">
        <input type="hidden" name="act" value="ticket">
        <input type="hidden" name="op" value="index">
    <input class="fl search" type="text" name="keyword" value="<?php echo $_GET['keyword']; ?>" placeholder="搜索景区">
    </form>
</header>
<div class="contect margin_bot">
    <div class="select_item flex_display">
        <!--<select class="flex-1 sele <?php /*echo isset($_GET['order'])?'connect':'move'; */?> haha" name="order">
            <option value="">默认排序</option>
            <option value="tk_show_price|asc" <?php /*echo $_GET['order']=='tk_show_price|asc'?'selected':'' */?>>价格从低到高</option>
            <option value="tk_show_price|desc" <?php /*echo $_GET['order']=='tk_show_price|desc'?'selected':'' */?>>价格从高到低</option>
            <option value="sales|asc" <?php /*echo $_GET['order']=='sales|asc'?'selected':'' */?>>销量从低到高</option>
            <option value="sales|desc" <?php /*echo $_GET['order']=='sales|desc'?'selected':'' */?>>销量从高到低</option>
        </select>
        <select class="flex-1 sele <?php /*echo isset($_GET['area'])?'connect':'move'; */?> haha" name="area">
            <option value="">所有地区</option>
            <?php /*foreach($output['area_arr'] as $k=>$v){ */?>
                <option value="<?php /*echo $v['tk_city_id']; */?>" <?php /*echo $_GET['area']==$v['tk_city_id']?'selected':'' */?>><?php /*echo $v['name']; */?></option>
            <?php /*}*/?>
        </select>
        <select class="flex-1 sele <?php /*echo isset($_GET['cate_id'])?'connect':'move'; */?> haha" name="cate_id">
            <option value="">所有分类</option>
            <?php /*foreach($output['cate'] as $k=>$v){*/?>
                <option value="<?php /*echo $v['tc_id']; */?>" <?php /*echo $_GET['cate_id']==$v['tc_id']?'selected':'' */?>><?php /*echo $v['tc_name']; */?></option>
            <?php /*} */?>
        </select>
-->
        <!--新的下拉标签-->

              <a class="flex-1 <?php echo isset($_GET['order'])?'color_blue':''; ?> haha" href="javascript:;">
                  <?php if(isset($_GET['order'])): ?>
                      <?php if($_GET['order']=='tk_show_price|asc'){ ?>
                          价格从低到高
                      <?php }elseif($_GET['order']=='tk_show_price|desc'){ ?>
                          价格从高到低
                      <?php }elseif($_GET['order']=='sales|asc'){ ?>
                          销量从低到高
                      <?php }elseif($_GET['order']=='sales|desc'){ ?>
                          销量从高到低
                      <?php }else{ ?>
                          默认排序
                      <?php } ?>
                  <?php else: ?>
                      默认排序
                  <?php endif; ?>
                  <i class="iconfont icon-xialalan"></i>
               </a>
                            <ul id="order">
                                <li id="">默认排序</li>
                                <li id="tk_show_price|asc">价格从低到高</li>
                                <li id="tk_show_price|desc">价格从高到低</li>
                                <li id="sales|asc">销量从低到高</li>
                                <li id="sales|desc">销量从高到低</li>
                            </ul>

                            <a class="flex-1 <?php echo isset($_GET['area'])?'color_blue':''; ?>  haha" href="javascript:;">
                                <?php if(isset($_GET['area'])): ?>
                                    <?php if($_GET['area']>0): ?>
                                        <?php foreach($output['area_arr'] as$k=>$v): ?>
                                            <span style="<?php if($_GET['area']!=$v['tk_area_id']){echo 'display: none;'; }; ?>"><?php echo $v['name']; ?></span>
                                        <?php endforeach ?>
                                    <?php else: ?>
                                        全部地区
                                    <?php endif; ?>
                                <?php else: ?>
                                    地区筛选
                                <?php endif; ?>
                                <i class="iconfont icon-xialalan"></i>
                            </a>
                            <ul id="area">
                                <li id="">全部城市</li>
                                <?php foreach($output['area_arr'] as$k=>$v): ?>
                                    <li id="<?php echo $v['tk_area_id']; ?>"><?php echo $v['name']; ?></li>
                                <?php endforeach ?>
                            </ul>

                            <a class="flex-1 <?php echo isset($_GET['cate_id'])?'color_blue':''; ?> haha" href="javascript:;">
                                <?php if(isset($_GET['cate_id'])): ?>
                                    <?php if($_GET['cate_id']>0): ?>
                                        <?php foreach($output['cate'] as$k=>$v): ?>
                                            <span style="<?php if($_GET['cate_id']!=$v['tc_id']){echo 'display: none;'; }; ?>"><?php echo $v['tc_name']; ?></span>
                                        <?php endforeach ?>
                                    <?php else: ?>
                                        全部分类
                                    <?php endif; ?>
                                <?php else: ?>
                                    全部分类
                                <?php endif; ?>
                                <i class="iconfont icon-xialalan"></i>
                            </a>

                            <ul id="cate_id">
                                <li id="">全部分类</li>
                                <?php foreach($output['cate'] as$k=>$v): ?>
                                    <li id="<?php echo $v['tc_id']; ?>"><?php echo $v['tc_name']; ?></li>
                                <?php endforeach ?>
                           </ul>
        <!--下拉标签结束-->

    </div>
    <ul class="item_ul">
    <?php foreach($output['ticket_list'] as $key =>$value): ?>
     <a href="index.php?act=ticket&op=ticket_info&tk_id=<?php echo $value['tk_id']; ?>">
        <li class="item_list">

            <span>已售：<?php echo $value['sales']; ?></span>
            <img src="<?php echo $value['tk_thumb']; ?>"/>
            <h5><?php echo $value['tk_title']; ?></h5>
            <p class="cleanfloat starFive sF1">
                <span class="org_star iconfont icon-xingxing"></span>
                <span class="org_star iconfont icon-xingxing"></span>
                <span class="org_star iconfont icon-xingxing"></span>
                <span class="org_star iconfont icon-xingxing"></span>
                <span class="org_star iconfont icon-xingxing"></span>
                <b><?php echo $value['grade']; ?>分</b>
            </p>
            <b><?php echo $value['area_name'] ?>/<?php echo $value['tk_addr']; ?></b><b><?php echo $value['distance']; ?></b>
            <span class="red fr"><i class="iconfont icon-renminbi"></i><?php echo $value['tk_show_price']; ?></span>
            <!--<div class="place_away"><b class="p-1"><?php /*echo $value['area_name'] */?>/<?php /*echo $value['tk_addr']; */?></b><b><?php /*echo $value['distance']; */?></b></div>
            <span class="red fr">￥<?php /*echo $value['tk_show_price']; */?></span>-->

        </li>
        </a>
        <?php endforeach; ?>
    </ul>
    <!--加载更多-->
    <div class="load" style="text-align: center;display: none;">
        <div class="loading" style="text-align: center;">正在加载中....</div>
    </div>
</div>
<script>
    //ajax加载分页

    var allNum = <?php echo $output['TotalNum']; ?>,
        allPage = <?php echo $output['TotalPage']; ?>,
        curPage = 1;

    var is_scroll = false;
    $(window).scroll(function () {
        is_scroll = true;
        //已经滚动到上面的页面高度
        var scrollTop = $(this).scrollTop();
        //页面高度
        var scrollHeight = $(document).height();
        //浏览器窗口高度
        var windowHeight = $(this).height();
        //此处是滚动条到底部时候触发的事件，在这里写要加载的数据，或者是拉动滚动条的操作
        if (scrollTop + windowHeight == scrollHeight) {
            $('.load').show();
            loadpage();
        }
    });
    function loadpage(){
        if(!is_scroll){
            return;
        }
        if (curPage < allPage) {
            curPage += 1;
        } else {
            $('.load').text('没有更多内容了').show();
            return;
        }
        $.get(location.href, {isajax:1,curpage:curPage},function(data){
            if(data){
                $(".item_ul").append(data);
                $('.load').hide();
            }
        });
    }

    //select 搜索
    $(".sele").change(function(){
        var name = $(this).attr('name')
        var val = $(this).val();
        window.location.href='index.php?act=ticket&'+name+'='+val;
    })

    //新下拉选项
        $(".select_item a").click(function () {
            $(this).addClass("color_blue").siblings().removeClass("color_blue");
            $(this).next("ul").slideToggle();
            $(this).next("ul").siblings("ul").css("display","none");

        });

        //文本传值
        $(".select_item li").click(function () {
            var i='<i class="iconfont icon-xialalan"></i>';
            $(this).parent().prev().html($(this).html()+i);
            $(this).parent("ul").slideUp();
            var name = $(this).parents('ul').attr('id');
            var val  = $(this).attr('id');
            window.location.href='index.php?act=ticket&'+name+'='+val;
        });
</script>
<?php if ($_SESSION['pos']['js'] == false /*&& strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') == false*/): ?>
    <script src="//webapi.amap.com/maps?v=1.4.3&key=e5c438490a60083b210b012342ff9339"></script>
    <script src="//cache.amap.com/lbs/static/es5.min.js"></script>
    <script>
        var mapObj = new AMap.Map('iCenter');
        var  geolocation;
        mapObj.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
                enableHighAccuracy: true,//是否使用高精度定位，默认:true
                timeout: 100000,          //超过10秒后停止定位，默认：无穷大
                maximumAge: 10000,           //定位结果缓存0毫秒，默认：0
                convert: true           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
            });

            geolocation.getCurrentPosition();
            mapObj.addControl(geolocation);
            AMap.event.addListener(geolocation, 'complete', onComplete); //返回定位信息
            AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
        });

        //获取经纬度
        function onComplete(data) {
            console.log(data.position.getLng());
            console.log(data.position.getLat());
            var lng = data.position.getLng();//经度
            var lat = data.position.getLat();//纬度
            $.getJSON('index.php?act=location&op=ajax',{lng:lng,lat:lat},function(json){
                /*json.reloads && json.city && popAlert('定位到'+json.city+'，将为您切换到'+json.city, function () {
                 location.reload();
                 }, 0);*/
                json.reloads && json.city && location.reload();
            });
        }
        function onError(data) {
            console.log(data);
            //popAlert('您禁用了定位' + e.message);
        }
    </script>
<?php endif; ?>
